/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ListItemUser.java
 *
 * Created on Jun 26, 2011, 1:29:58 PM
 */
package chat;

import chat.server.model.User;
import java.awt.Component;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 *
 * @author mingq
 */
public class ListItemUser extends javax.swing.JPanel implements ListCellRenderer {

    /** Creates new form ListItemUser */
    public ListItemUser() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbl_nick = new javax.swing.JLabel();
        lbl_online = new javax.swing.JLabel();
        lbl_msg = new javax.swing.JLabel();

        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(chat.ChatApp.class).getContext().getResourceMap(ListItemUser.class);
        lbl_nick.setText(resourceMap.getString("lbl_nick.text")); // NOI18N
        lbl_nick.setName("lbl_nick"); // NOI18N

        lbl_online.setText(resourceMap.getString("lbl_online.text")); // NOI18N
        lbl_online.setName("lbl_online"); // NOI18N

        lbl_msg.setText(resourceMap.getString("lbl_msg.text")); // NOI18N
        lbl_msg.setName("lbl_msg"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbl_nick)
                .addGap(28, 28, 28)
                .addComponent(lbl_online)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lbl_msg)
                .addContainerGap(247, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl_nick)
                    .addComponent(lbl_online)
                    .addComponent(lbl_msg))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        User user = (User) value;
        lbl_nick.setText(user.nick);
        lbl_online.setText(user.online ? "在线" : "离线");
        lbl_msg.setText(user.msg ? "有消息" : "");
        return this;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lbl_msg;
    private javax.swing.JLabel lbl_nick;
    private javax.swing.JLabel lbl_online;
    // End of variables declaration//GEN-END:variables
}
